<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微型相册系统</title>
    <link rel="stylesheet" href="/Album/Public/css/bootstrap.min.css">
    <script src="/Album/Public/js/jquery.js"></script>
    <script src="/Album/Public/js/bootstrap.min.js"></script>
    
        <link rel="stylesheet" href="/Album/Public/css/style.css">
    
</head>
<body>
    <header class="header">
        <span class="Index_logo">微型相册系统</span>
        <nav class="navbar navbar-default">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">主页</a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active" id="js_addalbum"><a href="#">添加相册 <span class="sr-only">(current)</span></a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">欢迎您！<?php echo (session('home')); ?></a></li>
                        <li><a href="<?php echo U('Login/loginOut');?>">❤退出❤</a></li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
    </header>
    
    <div class="panel panel-primary" id="js_album">
        <div class="panel-heading">
            相册系统
        </div>
        <div class="panel-body">
            <?php if(!empty($list)): if(is_array($list)): foreach($list as $key=>$v): ?><div class="col-xs-12 col-sm-6 col-md-4">
                <div class="thumbnail">

                    <img src="/Album<?php echo ($v['face']); ?>" alt="" style="height:350px;">
                    <div class="caption">
                        <h3><?php echo ($v['name']); ?></h3>
                        <p><a class="btn btn-primary js_check" role="button" pid="<?php echo ($v['id']); ?>">查看详情</a></p>
                    </div>

                </div>
            </div><?php endforeach; endif; ?>
                <?php else: ?>
                没有相册<?php endif; ?>
        </div>
    </div>
    <div class="modal fade" id="myModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">添加相册</h4>
                </div>
                <div class="modal-body">
                    <form action="<?php echo U('Index/addalbum');?>" method="post" enctype="multipart/form-data">
                        <div class="form-group">
                            <label for="exampleInputEmail1">相册名称</label>
                            <input type="text" name="name" class="form-control" id="exampleInputEmail1" placeholder="album">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputFile">相册</label>
                            <input type="file" id="exampleInputFile" name="face">
                            <p class="help-block">Example block-level help text here.</p>
                        </div>
                        <button type="submit" class="btn btn-primary">添加</button>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <script>
        $("#js_addalbum").click(function(){
            $('#myModal').modal('show');
        })

        $(".js_check").each(function(){
            $(this).click(function() {
                var id = $(this).attr('pid');
                 //alert(id);
                $.ajax({
                    type: "POST",        //发送格式
                    url: "<?php echo U('showphoto');?>",   //发送到哪里
                    async: true,        // 设置格式(异步)   默认异步
                    data: {'id': id},  //发送的参数
                    success: function (data) {
                        $("#js_album").replaceWith(data);
                    },
                    error: function () {
                        //请求出错处理
                        alert("Error!");
                    }
                })
            })
        })
    </script>


    <div class="footer">

    </div>
</body>
</html>